package com.crm.web.controller.clue;

import com.crm.common.core.controller.BaseController;
import com.crm.common.core.domain.AjaxResult;
import com.crm.common.core.page.TableDataInfo;
import com.crm.domain.ClueRecord;
import com.crm.service.IClueRecordService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;


@RestController
@RequestMapping("/clues/record")
@Slf4j
public class ClueRecordController extends BaseController {
    @Autowired
    private IClueRecordService clueRecordService;

    /**
     * 根据线索clueId操作查询记录
     * @param clueId
     * @return
     */
    @GetMapping("list")
    public TableDataInfo listByClueId(@RequestParam Long clueId){
        log.info("查询操作记录接收到的参数:{}",clueId);
        startPage();
        List<ClueRecord> clueRecordList = clueRecordService.listByClueId(clueId);
        return getDataTable(clueRecordList);
    }

    /**
     * 添加操作记录
     * @param clueRecord
     * @return
     */
    @PostMapping
    public AjaxResult add(@RequestBody ClueRecord clueRecord){
        log.info("添加操作记录接收到的参数:{}",clueRecord);
        clueRecordService.add(clueRecord);
        return AjaxResult.success();
    }
}
